home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksockssocketdevice.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.1 KB  |  130 lines

  1. /*  -*- C++ -*-
  2.  *  Copyright (C) 2004 Thiago Macieira <thiago.macieira@kdemail.net>
  3.  *
  4.  *  This library is free software; you can redistribute it and/or
  5.  *  modify it under the terms of the GNU Library General Public
  6.  *  License as published by the Free Software Foundation; either
  7.  *  version 2 of the License, or (at your option) any later version.
  8.  *
  9.  *  This library is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  *  Library General Public License for more details.
  13.  *
  14.  *  You should have received a copy of the GNU Library General Public License
  15.  *  along with this library; see the file COPYING.LIB.  If not, write to
  16.  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  *  Boston, MA 02110-1301, USA.
  18.  */
  19.  
  20. #ifndef KSOCKSSOCKETDEVICE_H
  21. #define KSOCKSSOCKETDEVICE_H
  22.  
  23. #include "ksocketdevice.h"
  24.  
  25. namespace KNetwork {
  26.  
  27. /** 
  28.  * @class KSocksSocketDevice ksockssocketdevice.h ksockssocketdevice.h
  29.  * @brief The low-level class for SOCKS proxying.
  30.  *
  31.  * This class reimplements several functions from @ref KSocketDevice in order
  32.  * to implement SOCKS support.
  33.  *
  34.  * This works by using KSocks.
  35.  *
  36.  * @author Thiago Macieira <thiago.macieira@kdemail.net>
  37.  *
  38.  * @warning This code is untested!
  39.  */
  40. class KDECORE_EXPORT KSocksSocketDevice: public KSocketDevice
  41. {
  42. public:
  43.   /** 
  44.    * Constructor.
  45.    */
  46.   KSocksSocketDevice(const KSocketBase* = 0L);
  47.  
  48.   /**
  49.    * Construct from a file descriptor.
  50.    */
  51.   explicit KSocksSocketDevice(int fd);
  52.  
  53.   /**
  54.    * Destructor.
  55.    */
  56.   virtual ~KSocksSocketDevice();
  57.  
  58.   /**
  59.    * Sets our capabilities.
  60.    */
  61.   virtual int capabilities() const;
  62.  
  63.   /**
  64.    * Overrides binding.
  65.    */
  66.   virtual bool bind(const KResolverEntry& address);
  67.  
  68.   /**
  69.    * Overrides listening.
  70.    */
  71.   virtual bool listen(int backlog);
  72.  
  73.   /**
  74.    * Overrides connection.
  75.    */
  76.   virtual bool connect(const KResolverEntry& address);
  77.  
  78.   /**
  79.    * Overrides accepting. The return type is specialised.
  80.    */
  81.   virtual KSocksSocketDevice* accept();
  82.  
  83.   /**
  84.    * Overrides reading.
  85.    */
  86.   virtual Q_LONG readBlock(char *data, Q_ULONG maxlen);
  87.   virtual Q_LONG readBlock(char *data, Q_ULONG maxlen, KSocketAddress& from);
  88.  
  89.   /**
  90.    * Overrides peeking.
  91.    */
  92.   virtual Q_LONG peekBlock(char *data, Q_ULONG maxlen);
  93.   virtual Q_LONG peekBlock(char *data, Q_ULONG maxlen, KSocketAddress& from);
  94.  
  95.   /**
  96.    * Overrides writing.
  97.    */
  98.   virtual Q_LONG writeBlock(const char *data, Q_ULONG len);
  99.   virtual Q_LONG writeBlock(const char *data, Q_ULONG len, const KSocketAddress& to);
  100.  
  101.   /**
  102.    * Overrides getting socket address.
  103.    */
  104.   virtual KSocketAddress localAddress() const;
  105.  
  106.   /**
  107.    * Overrides getting peer address.
  108.    */
  109.   virtual KSocketAddress peerAddress() const;
  110.  
  111.   /**
  112.    * Overrides getting external address.
  113.    */
  114.   virtual KSocketAddress externalAddress() const;
  115.  
  116.   /**
  117.    * Overrides polling.
  118.    */
  119.   virtual bool poll(bool* input, bool* output, bool* exception = 0L,
  120.             int timeout = -1, bool* timedout = 0L);
  121.  
  122. private:
  123.   static void initSocks();
  124.   friend class KSocketDevice;
  125. };
  126.  
  127. }                // namespace KNetwork
  128.  
  129. #endif
  130.